home *** CD-ROM | disk | FTP | other *** search
- Path: news.clark.net!not-for-mail
- From: gusty@clark.net (Harlan Messinger)
- Newsgroups: comp.lang.c++
- Subject: Re: Strange (to me) notation - little help?
- Date: 4 Jan 1996 22:07:58 GMT
- Organization: Clark Internet Services, Inc., Ellicott City, MD USA
- Message-ID: <4chj3u$l6s@clarknet.clark.net>
- References: <30EB32AC.2836@sierra.net> <4cg4bh$hp1@werple.net.au>
- NNTP-Posting-Host: explorer.clark.net
- Mime-Version: 1.0
- Content-Type: TEXT/PLAIN; charset=ISO-8859-1
- Content-Transfer-Encoding: 8bit
- X-Newsreader: TIN [UNIX 1.3 950726BETA PL0]
-
- David White (davidw@werple.net.au) wrote:
- : The colon introduces the constructor's initializer list, within which you
- : can initialize the base class constructor and any member objects. For
- : consistency with the initialization syntax used for user-defined types,
- : built-in types may use the same syntax, e.g., int x(5) creates an int and
- : gives it an initial value of 5. In your example, an initializer list is
- : not required; initialization could have been deferred to the c'tor body.
- : However, there are many cases in which an initializer list is necessary,
- : such as the construction of base class or member objects that do not have
- : default constructors, and reference members. For example:
-
- Also, constant member data have to be initialized this way.
-